]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellUserVerifier: fix cancellation
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 26 Aug 2012 12:54:02 +0000 (14:54 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 2 Sep 2012 21:09:23 +0000 (23:09 +0200)
Ensure that all async callbacks check and ignore G_IO_ERROR_CANCELLED.
Ensure that all runs of authentication have their own GCancellable, so
that .begin() can be called multiple times on the same user verifier.
Check for fingerprint reader when beginning authentication, and not
when reset by GDM.

https://bugzilla.gnome.org/show_bug.cgi?id=682544

js/gdm/util.js
js/ui/unlockDialog.js

index d07d1b2e5823ba1238f0d7b743157e12c4b3d376..d2e537a4cc85475f21900f53e46adf05c5a5b680 100644 (file)
@@ -79,18 +79,17 @@ const ShellUserVerifier = new Lang.Class({
 
         this._settings = new Gio.Settings({ schema: LOGIN_SCREEN_SCHEMA });
 
-        this._cancellable = new Gio.Cancellable();
-
         this._fprintManager = new Fprint.FprintManager();
-        this._checkForFingerprintReader();
-
         this._realmManager = new Realmd.Manager();
     },
 
     begin: function(userName, hold) {
+        this._cancellable = new Gio.Cancellable();
         this._hold = hold;
         this._userName = userName;
 
+        this._checkForFingerprintReader();
+
         if (userName) {
             // If possible, reauthenticate an already running session,
             // so any session specific credentials get updated appropriately
@@ -102,15 +101,18 @@ const ShellUserVerifier = new Lang.Class({
     },
 
     cancel: function() {
-        this._cancellable.cancel();
+        if (this._cancellable)
+            this._cancellable.cancel();
 
         if (this._userVerifier)
             this._userVerifier.call_cancel_sync(null);
-        this._cancellable = new Gio.Cancellable();
     },
 
     clear: function() {
-        this._cancellable.cancel();
+        if (this._cancellable) {
+            this._cancellable.cancel();
+            this._cancellable = null;
+        }
 
         if (this._userVerifier) {
             this._userVerifier.run_dispose();
@@ -144,11 +146,12 @@ const ShellUserVerifier = new Lang.Class({
             this._hold.release();
         } catch (e) {
             if (this._reauthOnly) {
-                logError(e, 'Failed to open reauthentication channel');
+                if (e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
+                    return;
 
-                this._hold.release();
+                logError(e, 'Failed to open reauthentication channel');
                 this.emit('verification-failed');
-
+                this._hold.release();
                 return;
             }
 
@@ -159,10 +162,14 @@ const ShellUserVerifier = new Lang.Class({
     },
 
     _userVerifierGot: function(client, result) {
-        this._userVerifier = client.get_user_verifier_finish(result);
+        try {
+            this._userVerifier = client.get_user_verifier_finish(result);
+        } catch(e if e.matches(Gio.IOErrorEnum, Gio.ErrorEnum.CANCELLED)) {
+            return;
+        }
+
         this._connectSignals();
         this._beginVerification();
-
         this._hold.release();
     },
 
@@ -184,7 +191,12 @@ const ShellUserVerifier = new Lang.Class({
                                                                 this._userName,
                                                                 this._cancellable,
                                                                 Lang.bind(this, function(obj, result) {
-                obj.call_begin_verification_for_user_finish(result);
+                try {
+                    obj.call_begin_verification_for_user_finish(result);
+                } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                    return;
+                }
+
                 this._hold.release();
             }));
 
@@ -195,7 +207,12 @@ const ShellUserVerifier = new Lang.Class({
                                                                     this._userName,
                                                                     this._cancellable,
                                                                     Lang.bind(this, function(obj, result) {
-                    obj.call_begin_verification_for_user_finish(result);
+                    try {
+                        obj.call_begin_verification_for_user_finish(result);
+                    } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                        return;
+                    }
+
                     this._hold.release();
                 }));
             }
@@ -203,7 +220,12 @@ const ShellUserVerifier = new Lang.Class({
             this._userVerifier.call_begin_verification(PASSWORD_SERVICE_NAME,
                                                        this._cancellable,
                                                        Lang.bind(this, function(obj, result) {
-                obj.call_begin_verification_finish(result);
+                try {
+                    obj.call_begin_verification_finish(result);
+                } catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
+                    return;
+                }
+
                 this._hold.release();
             }));
         }
@@ -271,8 +293,6 @@ const ShellUserVerifier = new Lang.Class({
         this._userVerifier.run_dispose();
         this._userVerifier = null;
 
-        this._checkForFingerprintReader();
-
         this.emit('reset');
     },
 
index a4d666dabd20ce0ad7f1a4c5d7df86d6f5528621..da10cecc15024157a2d8e56146869f73d538f53d 100644 (file)
@@ -166,6 +166,7 @@ const UnlockDialog = new Lang.Class({
     },
 
     _reset: function() {
+        this._userVerifier.clear();
         this._userVerifier.begin(this._userName, new Batch.Hold());
     },